package 递归实现组合型枚举2;

import java.util.Arrays;
import java.util.Scanner;

public class Main {
    static int N = 30, n, m;
    static int[] a = new int[N];
    static boolean[] st = new boolean[N];

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        n = in.nextInt();
        m = in.nextInt();
        for (int i = 0; i < n; i++) {
            a[i] = in.nextInt();
        }
        Arrays.sort(a, 0, n);
        dfs(0, 0);
    }

    private static void dfs(int u, int s) {
        if (s > m) {
            return;
        }
        if (s == m) {
            for (int i = 0; i < u; i++) {
                if (st[i]) {
                    System.out.print(a[i] + " ");
                }
            }
            System.out.println();
            return;
        }
        if (u == n) {
            return;
        }
        int k = u;
        while (k < n && a[k] == a[u]) {
            st[k++] = true;
            s++;
        }
        dfs(k, s);
        for (int i = k - 1; i >= u; i--) {
            st[i] = false;
            s--;
            dfs(k, s);
        }
    }
}
